/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author Minh Luc
 */
@Entity
@Table(name = "Users", catalog = "P2PDB", schema = "dbo", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"UserName"}),
    @UniqueConstraint(columnNames = {"Email"})})
@NamedQueries({
    @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
    @NamedQuery(name = "Users.findByUserId", query = "SELECT u FROM Users u WHERE u.userId = :userId"),
    @NamedQuery(name = "Users.findByUserName", query = "SELECT u FROM Users u WHERE u.userName = :userName"),
    @NamedQuery(name = "Users.findByPassword", query = "SELECT u FROM Users u WHERE u.password = :password"),
    @NamedQuery(name = "Users.findByTitleOfCourtesy", query = "SELECT u FROM Users u WHERE u.titleOfCourtesy = :titleOfCourtesy"),
    @NamedQuery(name = "Users.findByLastName", query = "SELECT u FROM Users u WHERE u.lastName = :lastName"),
    @NamedQuery(name = "Users.findByFristName", query = "SELECT u FROM Users u WHERE u.fristName = :fristName"),
    @NamedQuery(name = "Users.findByAddress", query = "SELECT u FROM Users u WHERE u.address = :address"),
    @NamedQuery(name = "Users.findByCity", query = "SELECT u FROM Users u WHERE u.city = :city"),
    @NamedQuery(name = "Users.findByRegion", query = "SELECT u FROM Users u WHERE u.region = :region"),
    @NamedQuery(name = "Users.findByPostalCode", query = "SELECT u FROM Users u WHERE u.postalCode = :postalCode"),
    @NamedQuery(name = "Users.findByMobilePhone", query = "SELECT u FROM Users u WHERE u.mobilePhone = :mobilePhone"),
    @NamedQuery(name = "Users.findByAvatarPath", query = "SELECT u FROM Users u WHERE u.avatarPath = :avatarPath"),
    @NamedQuery(name = "Users.findByEmail", query = "SELECT u FROM Users u WHERE u.email = :email"),
    @NamedQuery(name = "Users.findByCodeRegister", query = "SELECT u FROM Users u WHERE u.codeRegister = :codeRegister"),
    @NamedQuery(name = "Users.findByIsLock", query = "SELECT u FROM Users u WHERE u.isLock = :isLock"),
    @NamedQuery(name = "Users.findByAnswer", query = "SELECT u FROM Users u WHERE u.answer = :answer")})
public class Users implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "UserId", nullable = false)
    private Integer userId;
    @Column(name = "UserName", length = 50)
    private String userName;
    @Column(name = "Password", length = 50)
    private String password;
    @Column(name = "TitleOfCourtesy", length = 25)
    private String titleOfCourtesy;
    @Column(name = "LastName", length = 50)
    private String lastName;
    @Column(name = "FristName", length = 50)
    private String fristName;
    @Column(name = "Address", length = 50)
    private String address;
    @Column(name = "City", length = 50)
    private String city;
    @Column(name = "Region", length = 50)
    private String region;
    @Column(name = "PostalCode", length = 10)
    private String postalCode;
    @Column(name = "MobilePhone", length = 20)
    private String mobilePhone;
    @Column(name = "AvatarPath", length = 2147483647)
    private String avatarPath;
    @Column(name = "Email", length = 200)
    private String email;
    @Column(name = "CodeRegister", length = 50)
    private String codeRegister;
    @Column(name = "isLock")
    private Boolean isLock;
    @Column(name = "Answer", length = 2147483647)
    private String answer;
    @OneToMany(mappedBy = "users")
    private Collection<Rss> rssCollection;
    @JoinColumn(name = "RoleId", referencedColumnName = "RoleId")
    @ManyToOne
    private Roles roles;
    @JoinColumn(name = "JobId", referencedColumnName = "JobId")
    @ManyToOne
    private Job job;
    @OneToMany(mappedBy = "users")
    private Collection<Claim> claimCollection;
    @OneToMany(mappedBy = "userReply")
    private Collection<Feedback> feedbackCollection;
    @OneToMany(mappedBy = "userSend")
    private Collection<Feedback> feedbackCollection1;

    public Users() {
    }

    public Users(Integer userId) {
        this.userId = userId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getTitleOfCourtesy() {
        return titleOfCourtesy;
    }

    public void setTitleOfCourtesy(String titleOfCourtesy) {
        this.titleOfCourtesy = titleOfCourtesy;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFristName() {
        return fristName;
    }

    public void setFristName(String fristName) {
        this.fristName = fristName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    public String getMobilePhone() {
        return mobilePhone;
    }

    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }

    public String getAvatarPath() {
        return avatarPath;
    }

    public void setAvatarPath(String avatarPath) {
        this.avatarPath = avatarPath;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCodeRegister() {
        return codeRegister;
    }

    public void setCodeRegister(String codeRegister) {
        this.codeRegister = codeRegister;
    }

    public Boolean getIsLock() {
        return isLock;
    }

    public void setIsLock(Boolean isLock) {
        this.isLock = isLock;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public Roles getRoles() {
        return roles;
    }

    public void setRoles(Roles roles) {
        this.roles = roles;
    }

    public Job getJob() {
        return job;
    }

    public void setJob(Job job) {
        this.job = job;
    }

    public Collection<Rss> getRssCollection() {
        return rssCollection;
    }

    public void setRssCollection(Collection<Rss> rssCollection) {
        this.rssCollection = rssCollection;
    }

    public Collection<Claim> getClaimCollection() {
        return claimCollection;
    }

    public void setClaimCollection(Collection<Claim> claimCollection) {
        this.claimCollection = claimCollection;
    }

    public Collection<Feedback> getFeedbackCollection() {
        return feedbackCollection;
    }

    public void setFeedbackCollection(Collection<Feedback> feedbackCollection) {
        this.feedbackCollection = feedbackCollection;
    }

    public Collection<Feedback> getFeedbackCollection1() {
        return feedbackCollection1;
    }

    public void setFeedbackCollection1(Collection<Feedback> feedbackCollection1) {
        this.feedbackCollection1 = feedbackCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Users)) {
            return false;
        }
        Users other = (Users) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Users[userId=" + userId + "]";
    }
}
